<?php

Raise::load('core.helper.RaiseHelper');
Raise::load('core.helper.sorting.IRaiseComparator');

/**
 * RaiseTimeSpanComparator class
 * Comparator for RaiseTimeSpan objects
 *
 * @author Sam-Mauris Yong / hellclanner at live dot com
 * @license http://www.opensource.org/licenses/bsd-license New BSD License
 * @package phpraise.core.datetime
 * @since 1.2
 */
class RaiseTimeSpanComparator extends RaiseHelper implements IRaiseComparator {
    
    /**
     * Compare between two time span objects
     * @param RaiseTimeSpan $time1 The first time span object
     * @param RaiseTimeSpan $time2 The second time span object
     * @return integer Return 0 if both values are equal, 1 if $time2 > $time1 and -1 if $time2 < $time1
     */
    public function compare($time1, $time2){
        return $time1->totalSeconds() < $time2->totalSeconds() ? -1 : 1;
    }
    
}